package com.cy.common.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**封装服务端响应到客户端的数据,通过此对象定义一种规范会的格式*/
@Data
@NoArgsConstructor
public class JsonResult implements Serializable {
    private static final long serialVersionUID = 1018010862839495031L;
    /**状态:1 ok,0 error*/
    private Integer state=1;
    /**状态信息*/
    private String message="ok";
    /**业务层返回的正确响应数据*/
    private Object data;
    public JsonResult(String message){//new JsonResult("update ok")
        this.message=message;
    }
    public JsonResult(Object data){
        this.data=data;
    }
    public JsonResult(Throwable t){
        this.state=0;
        this.message= t.getMessage();

    }
}
